<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .big{
            display: flex;
            align-items: center;/*垂直居中*/
            justify-content: center;/*水平居中*/
            width:300px;
            height: 300px;
            background-color:gray;
        }
        .small{
            width:100px;
            height: 100px;
            background-color:red;
        }
    </style>
</head>
<body onclick="show('body')">
    <a href="https://baidu.com" onclick="btn()">百度</a>
    <div class="big" onclick="show('big')">
        <div class="small" onclick="show('sm')"></div>
    </div>
</body>
<script>
    function btn(){
        alert("aa");
        event.preventDefault();//取消标签的默认行为
    }
    function show(t){
        console.log(t);
        event.stopPropagation();//阻止冒泡
    }
</script>
</html>